const fs = require("fs");
const cheerio = require("cheerio");
const { html } = require("./list.js")
const axios = require("axios");



let $ = cheerio.load(html);

let link = $("#productlistul a");

let arr = [];
init();
async function init() {
    for (var i = 0; i < link.length; i++) {
        url = 'https://www.edifier.com/' + link.eq(i).attr("href");
        console.log(url);
        let options = {
            url: url,
            headers: {
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36"
            }
        }
        let response = await axios(options);

        let $$ = cheerio.load(response.data)

        let others = $$("#ohters").html()
        arr.push({
            others: others,
        })
        console.log(arr);

    }

}


// fs.writeFile("goods.json", JSON.stringify(arr), err => {
//     if (err) throw err;
//     console.log("成功");
// })